package javaBase.javaIO;

import java.io.*;
import java.util.Date;

/**
 * Created by Administrator on 2017/5/15 0015.
 */
public class FileCount {
    public static void main(String[] args) {
        int count = 0;
        InputStream streamReader = null;
        OutputStream streamwirte = null;
        try {
            streamReader = new FileInputStream("D:/logs/mylog.log");
            streamwirte = new FileOutputStream("D:/logs/create.txt");
            Date date = new Date();
            System.out.println("date=="+date);
            byte[] b = new byte[8];
            int byteread = 0;
            while ( (byteread=streamReader.read(b))!=-1) {
                count++;
                System.out.write(b,0,byteread);
            }
            System.out.println("date=="+new Date());
            System.out.println("文件长度是" + count);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                streamReader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
